//window.addEventListener("load",function(){
//    var startTimeStamp=new Date().getTime();
//    var box=document.getElementById("box");
//    var timer=setInterval(function(){
//        var t=(new Date().getTime()-startTimeStamp)/1000; //经过的秒数
//        console.log(t);
//
//        box.style.height=(t*t*t-5*t*t+5*t+10)*10+"px";
//
//        if(t>5) clearInterval(timer); //
//    },50);
//});

//数据绑定暂用 control-XXX 
$(function(){
	//二维码
	/*
	var QRcode = (function(){
		console.log('qrcode')
		var link = 'http://qr.liantu.com/api.php?text=';
		var local = window.location.href;
		var QRsrc = link+local;
		var $img = $('.control-QR')
		var change = function(){
			$img.get(0).src = QRsrc;
		}
		change()
		return change
	})()*/

	//导航栏
	var nav = (function(){
		var $nav = $('.left');
		var $goods = $('.right');
		var $menus = $nav.find('a.menu');
		$menus.click(function(){
			var data = $(this).attr('data-nav');
			highLight($(this))
			scrollTo(data)
		})
		$(window).scroll(function(event) {
			var windowScroll = $(this).scrollTop();
			//console.log(windowScroll)
			var $currentItem = $('');
			$('.goods-plate').each(function(index, el) {
				var min = $(el).get(0).offsetTop-windowScroll
				if(min<180){
					console.log(1)
					$currentItem = $(el)
				}else{
					return false
				}
			});
			var attr = $currentItem.attr('data-nav');
			var $currentNav = $nav.find("[data-nav='"+attr+"']");
			//console.log()
			highLight($currentNav)
		});

		function scrollTo(attr){
			var $sharp = $goods.find("[data-nav='"+attr+"']");
			console.log($sharp)
			//$(window).scrollTop($sharp[0].offsetTop-120)
			$('html,body').animate({scrollTop:$sharp[0].offsetTop-120}, 500)
		}

		function highLight($item){
			$menus.removeClass('menu-normal').addClass('menu-label');
			$item.removeClass('menu-label').addClass('menu-normal')
		}
	})()

})
